<template>
    <div>
        <slot></slot>
    </div>
</template>

<script>
export default {
    props: {
        value: {
            type: Array,
            default: [],
        },
    },
    created() {
        // 监听item-click事件，并添加该事件触发时的回调函数
        this.$on("item-click", (item) => {
            let index = this.value.indexOf(item.name);

            if (index > -1) {
                this.value.splice(index, 1);
            } else {
                this.value.push(item.name);
            }
        });
    },
    provide() {
        return {
            collapse: this,
        };
    },
};
</script>

<style lang="less" scoped>
</style>